package com.sanqi.work.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sanqi.common.annotation.Log;
import com.sanqi.common.core.controller.BaseController;
import com.sanqi.common.core.domain.AjaxResult;
import com.sanqi.common.enums.BusinessType;
import com.sanqi.work.domain.WorkScoreConf;
import com.sanqi.work.service.IWorkScoreConfService;
import com.sanqi.common.utils.poi.ExcelUtil;
import com.sanqi.common.core.page.TableDataInfo;

/**
 * 工作指标配置Controller
 * 
 * @author duany
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/work/scorconf")
@Api(tags="工作指标配置")
public class WorkScoreConfController extends BaseController
{
    @Autowired
    private IWorkScoreConfService workScoreConfService;

    /**
     * 查询工作指标配置列表
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:list')")
    @GetMapping("/list")
    @ApiOperation(value="工作指标配置-查询工作指标配置列表", notes="工作指标配置-查询工作指标配置列表")
    public TableDataInfo list(WorkScoreConf workScoreConf)
    {
        startPage();
        List<WorkScoreConf> list = workScoreConfService.selectWorkScoreConfList(workScoreConf);
        return getDataTable(list);
    }

    /**
     * 导出工作指标配置列表
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:export')")
    @Log(title = "工作指标配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value="工作指标配置-导出工作指标配置列表", notes="工作指标配置-导出工作指标配置列表")
    public void export(HttpServletResponse response, WorkScoreConf workScoreConf)
    {
        List<WorkScoreConf> list = workScoreConfService.selectWorkScoreConfList(workScoreConf);
        ExcelUtil<WorkScoreConf> util = new ExcelUtil<WorkScoreConf>(WorkScoreConf.class);
        util.exportExcel(response, list, "工作指标配置数据");
    }

    /**
     * 获取工作指标配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value="工作指标配置-获取工作指标配置详细信息", notes="工作指标配置-获取工作指标配置详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(workScoreConfService.selectWorkScoreConfById(id));
    }

    /**
     * 新增工作指标配置
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:add')")
    @Log(title = "工作指标配置", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="工作指标配置-新增工作指标配置", notes="工作指标配置-新增工作指标配置")
    public AjaxResult add(@RequestBody WorkScoreConf workScoreConf)
    {
        return toAjax(workScoreConfService.insertWorkScoreConf(workScoreConf));
    }

    /**
     * 修改工作指标配置
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:edit')")
    @Log(title = "工作指标配置", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="工作指标配置-修改工作指标配置", notes="工作指标配置-修改工作指标配置")
    public AjaxResult edit(@RequestBody WorkScoreConf workScoreConf)
    {
        return toAjax(workScoreConfService.updateWorkScoreConf(workScoreConf));
    }

    /**
     * 删除工作指标配置
     */
    @PreAuthorize("@ss.hasPermi('work:scorconf:remove')")
    @Log(title = "工作指标配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	@ApiOperation(value="工作指标配置-删除工作指标配置", notes="工作指标配置-删除工作指标配置")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(workScoreConfService.deleteWorkScoreConfByIds(ids));
    }
}
